package com.ruoyi.hospital.controller.storeInfo;

import java.util.List;

import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hospital.domain.storeInfo.PharmacyStoreInfo;
import com.ruoyi.hospital.service.storeInfo.IPharmacyStoreInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 药店管理Controller
         *
         * @author wendao
        * @date 2024-08-13
        */
@RestController
@RequestMapping("/hospital/storeInfo")
public class PharmacyStoreInfoController extends BaseController
{
    @Autowired
    private IPharmacyStoreInfoService pharmacyStoreInfoService;

    /**
     * 查询药店管理列表
     */
    @PreAuthorize("@ss.hasPermi('manager:storeInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(PharmacyStoreInfo pharmacyStoreInfo)
    {
        startPage();
        List<PharmacyStoreInfo> list = pharmacyStoreInfoService.selectPharmacyStoreInfoList(pharmacyStoreInfo);
        return getDataTable(list);
    }

    /**
     * 导出药店管理列表
     */
    @PreAuthorize("@ss.hasPermi('manager:storeInfo:export')")
    @Log(title = "导出药店管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PharmacyStoreInfo pharmacyStoreInfo)
    {
        List<PharmacyStoreInfo> list = pharmacyStoreInfoService.selectPharmacyStoreInfoList(pharmacyStoreInfo);
        ExcelUtil<PharmacyStoreInfo> util = new ExcelUtil<PharmacyStoreInfo>(PharmacyStoreInfo.class);
        util.exportExcel(response, list, "药店管理数据");
    }

    /**
     * 获取药店管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('manager:storeInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(pharmacyStoreInfoService.selectPharmacyStoreInfoById(id));
    }

    /**
     * 新增药店管理
     */
    @PreAuthorize("@ss.hasPermi('manager:storeInfo:add')")
    @Log(title = "新增药店管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PharmacyStoreInfo pharmacyStoreInfo)
    {
        return toAjax(pharmacyStoreInfoService.insertPharmacyStoreInfo(pharmacyStoreInfo));
    }

    /**
     * 修改药店管理
     */
    @PreAuthorize("@ss.hasPermi('manager:storeInfo:edit')")
    @Log(title = "修改药店管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PharmacyStoreInfo pharmacyStoreInfo)
    {
        return toAjax(pharmacyStoreInfoService.updatePharmacyStoreInfo(pharmacyStoreInfo));
    }

    /**
     * 删除药店管理
     */
    @PreAuthorize("@ss.hasPermi('manager:storeInfo:remove')")
    @Log(title = "删除药店管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(pharmacyStoreInfoService.deletePharmacyStoreInfoByIds(ids));
    }
}